home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: gnu.gcc.help,comp.lang.c
- Subject: Re: Is this a compiler bug?
- Date: 02 Mar 1996 19:49:11 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Mar2124911@qcd.lanl.gov>
- References: <3135FEDB.65AA@carbon.chem.nyu.edu> <4h991r$qon@segfault.monkeys.com>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: rfg@monkeys.com's message of 2 Mar 1996 02:48:27 -0800
-
- In article <4h991r$qon@segfault.monkeys.com>
- rfg@monkeys.com (Ronald F. Guilmette) writes:
-
- <snip>
- RFG: >carbon% head static*.c
- RFG: >==> static_bug.c <==
- RFG: >static const char foo[];
- RFG: >
- RFG: >int
- RFG: >main(int argc, const char *argv[]) {
- RFG: > printf("foo = '%s'\n",foo);
- RFG: > return 0;
- RFG: >}
- RFG: >
- RFG: >#ifdef DEFINE_IT
- RFG: >static const char foo[] = "bar";
- RFG: >#endif
- RFG: >
- RFG: >==> static_bug2.c <==
- RFG: >const char foo[] = "baz";
- RFG: >carbon% gcc static*.c
- RFG: >carbon% a.out
- RFG: >foo = 'baz'
- RFG:
- RFG: I believe that in this case, the proper ANSI required behavior would be to
- RFG: print:
- RFG:
- RFG: foo = ''
-
- No. It is undefined.
-
- RFG:
- RFG: because there is some special clause in the C standard about tenative
- RFG: declarations (e.g. your first declaration of the `foo' array) and their
- RFG: handling at the end of a translation unit (i.e. `static_bug.c') in cases
- RFG: where no non-tenative declaration/definition has been provided... and that
- RFG: rule says that the compiler must act as if the data object in question
- RFG: has an initializer of zero. Thus, I believe that the compiler should
- RFG: simulate the following definition at the end of the translation unit
- RFG: unit `static_bug.c':
- RFG:
- RFG: static const char foo[] = { 0 };
-
- Except that a tentative declaration of an identifier with internal
- linkage cannot specify an incomplete type.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-